<?php
class My_Decorator_Element extends Zend_Form_Decorator_Abstract
{
	public function render($content)
	{
		$element = $this->getElement();
		
		if(null === ($view = $element->getView())){
			return $content;
		}
		
		$html = '';
		$boxes = '';
		
		$baseName = $element->getName();
		$baseLabel = $element->getLabel();
		$attribs = array();
		
		if($element->isRequired()){
			$attribs = array(
				'class' => 'required'
			);
		}
		
		if($element instanceof Zend_Form_Element_Text){
			$value = $element->getValue();
			$boxes = $view->formLabel($baseName,$baseLabel).
					 $view->formText($baseName,$value,$attribs);
		}elseif($element instanceof Zend_Form_Element_Textarea){
			$value = $element->getValue();
			$boxes = $view->formLabel($baseName,$baseLabel).
					 $view->formTextarea($baseName,$value,$attribs);
		}
		
		$html .= "<div class='row'>"
		      .  $boxes
			  .  "</div>";
		
		$placement = $this->getPlacement();
		$separator = $this->getSeparator();
		switch($placement){
			case 'APPEND':
				return $content.$separator.$html;
			case 'PREPEND':
				return $html.$separator.$content;
			case null:
			default:
				return $html;
		}
	}
}